import java.math.BigInteger;
import java.util.Arrays;

public class AppleTrees {
	private static final long MOD = 1000000007;

	public int theCount(int D, int[] r) {
		int n = r.length;
		long[][] q = new long[n + 1][80 * n + 1];
		q[1][0] = 1;
		long[][] qq = new long[n + 1][80 * n + 1];
		Arrays.sort(r);
		for (int i = n - 1; i >= 0; i--) {
			for (int j = 1; j <= n; j++) {
				for (int k = 0; k <= 80 * n; k++) {
					if (q[j][k] == 0)
						continue;
					qq[j - 1][k] += q[j][k] * j;
					qq[j][k + r[i] - 1] += q[j][k] * 2 * j;
					if (j < n)
						qq[j + 1][k + 2 * r[i] - 2] += q[j][k] * j;
				}
			}
			for (int j = 0; j <= n; j++) {
				for (int k = 0; k <= 80 * n; k++) {
					q[j][k] = qq[j][k] % MOD;
					qq[j][k] = 0;
				}
			}
		}
		long[] f = new long[D + n + 1];
		long[] of = new long[D + n + 1];
		f[0] = of[0] = 1;
		BigInteger mod = BigInteger.valueOf(MOD);
		for (int i = 1; i <= D + n; i++) {
			f[i] = (f[i - 1] * i) % MOD;
			of[i] = (of[i - 1] * BigInteger.valueOf(i).modInverse(mod).longValue()) % MOD;
		}
		long ans = 0;
		for (int i = n; i <= 81 * n && i <= D; i++) {
			long cur = (q[0][i - n] * f[D - i + n]) % MOD;
			cur = (cur * of[n]) % MOD;
			cur = (cur * of[D - i]) % MOD;
			ans += cur;
		}
		return (int) (ans % MOD);
	}

// BEGIN CUT HERE
   public static void main(String[] args) {
		if ( args.length == 0 ) {
			AppleTreesHarness.run_test(-1);
		} else {
			for ( int i=0; i<args.length; ++i )
				AppleTreesHarness.run_test(Integer.valueOf(args[i]));
		}
	}
// END CUT HERE
}

// BEGIN CUT HERE
class AppleTreesHarness {
	public static void run_test( int casenum ) {
		if ( casenum != -1 ) {
			if ( runTestCase( casenum ) == -1 )
				System.err.println("Illegal input! Test case " + casenum + " does not exist.");
			return;
		}
		
		int correct = 0, total = 0;
		for ( int i=0;; ++i ) {
			int x = runTestCase(i);
			if ( x == -1 ) {
				if ( i >= 100 ) break;
				continue;
			}
			correct += x;
			++total;
		}
		
		if ( total == 0 ) {
			System.err.println("No test cases run.");
		} else if ( correct < total ) {
			System.err.println("Some cases FAILED (passed " + correct + " of " + total + ").");
		} else {
			System.err.println("All " + total + " tests passed!");
		}
	}
	
	static boolean compareOutput(int expected, int result) { return expected == result; }
	static String formatResult(int res) {
		return String.format("%d", res);
	}
	
	static int verifyCase( int casenum, int expected, int received ) { 
		System.err.print("Example " + casenum + "... ");
		if ( compareOutput( expected, received ) ) {
			System.err.println("PASSED");
			return 1;
		} else {
			System.err.println("FAILED");
			System.err.println("    Expected: " + formatResult(expected)); 
			System.err.println("    Received: " + formatResult(received)); 
			return 0;
		}
	}

	static int runTestCase( int casenum ) {
		switch( casenum ) {
		case 0: {
			int D                     = 10;
			int[] r                   = {40};
			int expected__            = 10;

			return verifyCase( casenum, expected__, new AppleTrees().theCount( D, r ) );
		}
		case 1: {
			int D                     = 4;
			int[] r                   = {1, 1, 1, 1};
			int expected__            = 24;

			return verifyCase( casenum, expected__, new AppleTrees().theCount( D, r ) );
		}
		case 2: {
			int D                     = 4;
			int[] r                   = {1, 1, 2};
			int expected__            = 4;

			return verifyCase( casenum, expected__, new AppleTrees().theCount( D, r ) );
		}
		case 3: {
			int D                     = 58;
			int[] r                   = {5, 8};
			int expected__            = 2550;

			return verifyCase( casenum, expected__, new AppleTrees().theCount( D, r ) );
		}
		case 4: {
			int D                     = 47;
			int[] r                   = {4, 8, 9};
			int expected__            = 28830;

			return verifyCase( casenum, expected__, new AppleTrees().theCount( D, r ) );
		}
		case 5: {
			int D                     = 100000;
			int[] r                   = {21, 37, 23, 13, 32, 22, 9, 39};
			int expected__            = 923016564;

			return verifyCase( casenum, expected__, new AppleTrees().theCount( D, r ) );
		}

		// custom cases

/*      case 6: {
			int D                     = ;
			int[] r                   = ;
			int expected__            = ;

			return verifyCase( casenum, expected__, new AppleTrees().theCount( D, r ) );
		}*/
/*      case 7: {
			int D                     = ;
			int[] r                   = ;
			int expected__            = ;

			return verifyCase( casenum, expected__, new AppleTrees().theCount( D, r ) );
		}*/
/*      case 8: {
			int D                     = ;
			int[] r                   = ;
			int expected__            = ;

			return verifyCase( casenum, expected__, new AppleTrees().theCount( D, r ) );
		}*/
		default:
			return -1;
		}
	}
}

// END CUT HERE
